<template>
  <a-config-provider :locale='locale'>
      <router-view></router-view>
  </a-config-provider>
</template>

<script lang='ts' setup>
  import { ref } from 'vue'
  import zhCN from 'ant-design-vue/es/locale/zh_CN';
  import en_US from 'ant-design-vue/es/locale/en_US';
  import dayjs from 'dayjs';
  import 'dayjs/locale/zh-cn';
  import { useI18nStore } from './store/i18n';
import { useLocationStore } from './store';

  const locationStore = useLocationStore()

  if (navigator.geolocation) {  
      navigator.geolocation.getCurrentPosition((res) => {
        if(res && res.coords) {
          locationStore.longitude = res.coords.longitude
          locationStore.latitude = res.coords.latitude
        }
      });  
  } 
  

  const i18n = useI18nStore()
  

  

  const locale = ref()
  if(i18n.locale == 'ZH') {
    locale.value = zhCN
    dayjs.locale('zh-cn');
  }else {
    locale.value = en_US
    dayjs.locale('en-us');
  }
</script>
